<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\web\View;
use yii\data\ArrayDataProvider;

/* @var $this yii\web\View */
/* @var $searchModel app\models\ActivitySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '综合查询';
$this->params['breadcrumbs'][] = $this->title;
$js=<<< Js
var exportLink = document.getElementById('export');
	exportLink.addEventListener('click', function(e){
		e.preventDefault();
		if(e.target.nodeName === "A"){
			tableExport('table-export', '导出文件', e.target.getAttribute('data-type'));
		}

	}, false);
Js;
$this->registerJs($js, View::POS_END, 'myAjax');

?>
<script src="<?= \Yii::getAlias('@web')?>/js/Blob.js"></script>

<script src="<?= \Yii::getAlias('@web')?>/js/FileSaver.js"></script>

<script src="<?= \Yii::getAlias('@web')?>/js/tableExport.js"></script>
<div class="activity-model-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
         <div id="export" ><a class="btn btn-info"  data-type="xls" href="javascript:;">导出excel</a></div>	
    </p>
    <div class="table-responsive"> 
    
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
       	//'filterModel' => $searchModel,
    	'tableOptions'=>[
    				'id'=>'table-export',
    				'class' => 'table table-striped table-bordered',
    		],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
        		
            'stu_id'=>[
            		'attribute'=>'stu_id',
            		'label'=>'学号'
            ],
        	'stu_name'=>[
            		'attribute'=>'stu_name',
            		'label'=>'姓名'
            ],
            'sex'=>[
            		'value'=>function ($data){
            		return ($data['sex']==0)?'男':'女';            		
        			},
        			'attribute'=>'sex',
        			'filter'=>['0'=>'男','1'=>'女'],
        			'label'=>'性别'
        		],
        	'card_id'=>[
        				'value'=> function($data){
        				$r="'".$data['card_id'];
        				return $r;
        				} ,
        				'attribute'=>'card_id',
        				'label'=>'居民身份证号码'
        						],
             'used_name'=>[
            		'attribute'=>'used_name',
            		'label'=>'曾用名'
            ],
             'nation'=>[
            		'attribute'=>'nation',
            		'label'=>'民族'
            ],
             'political'=>[
            		'attribute'=>'political',
            		'label'=>'政治面貌'
            ],
             'nativeplace'=>[
            		'attribute'=>'nativeplace',
            		'label'=>'籍贯'
            ],
             'religion'=>[
            		'attribute'=>'religion',
            		'label'=>'宗教'
            ],
             'height'=>[
            		'attribute'=>'height',
            		'label'=>'身高'
            ],
             'maritial_status'=>[
            		'attribute'=>'maritial_status',
            		'label'=>'婚姻状况'
            ],
             'blood_type'=>[
            		'attribute'=>'blood_type',
            		'label'=>'血型'
            ],
             'telephone'=>[
            		'attribute'=>'telephone',
            		'label'=>'联系电话'
            ],
             'qq'=>[
            		'attribute'=>'qq',
            		'label'=>'QQ号'
            ],
             'blank'=>[
            		'attribute'=>'blank',
            		'label'=>'银行'
            ],
            'blank_num'=>[
            		'value'=> function($data){
            		$r="'".$data['blank_num'];
            		return $r;
            		} ,
            		'attribute'=>'blank_num',
            		'label'=>'银行卡号'
            	],
            
            				
            'stu_type'=>[
           			'value'=>function ($data){
            						if($data['stu_type']==0)
            							$stu_type='本科生';
            							elseif ($data['stu_type']==0)
            							$stu_type='硕士研究生';
            							else
            								$stu_type='博士研究生';
            								return $stu_type;
            						},
            		'attribute'=>'stu_type',
            		'filter'=>['0'=>'本科生','1'=>'硕士研究生','2'=>'博士研究生'],
            		'label'=>'学生类别',
            	],
           	'enroll_time'=>[
            		'attribute'=>'enroll_time',
            		'label'=>'入学时间'
            ],
           	'major_name'=>[
            		'attribute'=>'major_name',
            		'label'=>'专业名称'
            ],
            'class_name'=>[
            		'attribute'=>'class_name',
            		'label'=>'班级名称'
            ],
            						 
       		'status'=>[
            		'value'=>function ($data){
            							if($data['status']==0)
            								$status='在读';
            								elseif ($data['status']==1)
            								$status='休学';
            								elseif($data['status']==2)
            								$status='退学';
            								elseif($data['status']==3)
            								$status='保留入学资格';
           									elseif($data['status']==4)
           									$status='毕业';
           									elseif($data['status']==5)
           									$status='肄业';
           									elseif($data['status']==7)
           									$status='在读（在外校交流）';
           									elseif($data['status']==8)
           									$status='在本校交流学习';
           									elseif($data['status']==9)
           									$status='在本校交流学习结束';
           									else
           										$status='开除';
            										return $status;
            								},
            			'attribute'=>'status',
          				'filter'=>['0'=>'在读','1'=>'休学','2'=>'退学','3'=>'保留入学资格','4'=>'毕业','5'=>'肄业','6'=>'开除','7'=>'在读（在外校交流）',
            										'8'=>'在本校交流学习','9'=>'在本校交流学习结束'],
            			'label'=>'学籍状态'
       			], 
       			'dorm_area'=>[
       					'value'=>function ($data){
       					if($data['dorm_area']==0)
       						$dorm_area='东校园';
       						elseif ($data['dorm_area']==1)
       						$dorm_area='西校园';
       						else
       							$dorm_area='西校园南区';
       							return $dorm_area;
       					},
       					'attribute'=>'dorm_area',
       					'filter'=>['0'=>'东校园','1'=>'西校园','2'=>'西校园南区'],
       					 'label'=>'宿舍区'
       					],
       			'dormitory'=>[
       					'attribute'=>'dormitory',
       					'label'=>'宿舍楼'
       					],
       			'dorm_num'=>[
       					'attribute'=>'dorm_num',
       					'label'=>'宿舍号'
       					],
       			'leader'=>[
       					'attribute'=>'leader',
       					'label'=>'宿舍管理学生干部'
       					],
       			'address'=>[
       					'attribute'=>'address',
       					'label'=>'家庭详细通讯地址'
       					],
       			'recipient'=>[
       					'attribute'=>'recipient',
       					'label'=>'收件人'
       					],
       			'postal_code'=>[
       					'attribute'=>'postal_code',
       					'label'=>'邮政编码'
       					],
       			'economic_status'=>[
       					'attribute'=>'economic_status',
       					'label'=>'家庭经济状况'
       					],
       			'load'=>[
       					'attribute'=>'load',
       					'label'=>'助学贷款类型'
       					],
       					
          
        ],
    ]); ?>
    </div>
</div>
